package com.bw.shop2208a

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.SPUtils
import com.blankj.utilcode.util.ToastUtils
import com.bw.shop2208a.databinding.ActivityMain2Binding
import com.bw.shop2208a.databinding.ActivityMainBinding
import com.bw.shop2208a.db.DBUtils
import com.bw.shop2208a.entity.DataUserResult
import com.bw.shop2208a.mvvm.BaseViewActivity
import kotlinx.coroutines.launch

@Route(path = "/app/main")
class MainActivity : BaseViewActivity<ActivityMain2Binding>() {

//    @JvmField
//    @Autowired
//    var name = ""
//    @JvmField
//    @Autowired
//    var pass = ""

    @Autowired
    lateinit var user: DataUserResult
    override fun initViwe() {
//        ARouter.getInstance().inject(this)//这行一定要存在，不然不会进行赋值操作----一定注意先后顺序，不然可能会出现空指针异常
        /**
         * 如果直接从欢迎页跳转到此界面，传值类型为序列化是，会报错  传值类型为字符串时，不会报错
         */
        //找到fragment
        val navHostFragment =
            supportFragmentManager.findFragmentById(R.id.fragmentContainerView) as NavHostFragment
        //找到控制器
        val navController = navHostFragment.navController
        //进行绑定
        binding.bnv.setupWithNavController(navController)
//        lifecycleScope.launch {
//            val result =
//                DBUtils.getMyDataBaer().getUserDao().getUserById(SPUtils.getInstance().getInt("id"))
//            if (result != null) {
//                ToastUtils.showLong(result.nickname)
//            }
//        }

    }

    override fun iniData() {

    }

    override fun getLayoutId(): Int = R.layout.activity_main2

}